import * as service from "@/service";
import { IDis1, IDis2 } from "./interface";
const dis1: IDis1 = {
  namespaced: true,
  state: {
    diss: [],
  },
  actions: {
    async getdis1({ commit }) {
      const res = await service.dis1();
      const action = {
        type: "GET_DIS", //要传递到mutations的GET_DIS里面
        res: res,
      };
      commit(action);
    },
  },
  mutations: {
    GET_DIS(state, { res }) {
      //mutations里面的函数接收第一个参数是state,第二个参数是res
      state.diss = res;
    },
  },
};

const dis2: IDis2 = {
  namespaced: true,
  state: {
    diss: [],
  },
  actions: {
    async getdis1({ commit }, { id }) {
      const res = await service.dis2(id);
      const action = {
        type: "GET_DIS",
        res: res,
      };
      commit(action);
    },
  },
  mutations: {
    GET_DIS(state, { res }) {
      state.diss = res;
    },
  },
};
export { dis1, dis2 };
